1.1 --- a/libfsclient/lib/src/file.cc Sat Dec 09 01:26:55 2023 +0100
1.2 +++ b/libfsclient/lib/src/file.cc Sat Dec 09 01:27:19 2023 +0100
1.3 @@ -611,96 +611,47 @@
1.4
1.5
1.6
1.7 -/* Opaque notifier type for file_notifier_t. */
1.8 -
1.9 -struct file_notifier
1.10 -{
1.11 - ObjectNotifier *obj;
1.12 -};
1.13 -
1.14 /* Conversion to the generic notification types. */
1.15
1.16 notifiable_t *file_notifiable(file_t *file)
1.17 {
1.18 - return &file->notifiable;
1.19 + return notify_notifiable((notifiable_base_t *) file);
1.20 }
1.21
1.22 /* Return the notification flags for a file. */
1.23
1.24 notify_flags_t file_notifications(file_t *file)
1.25 {
1.26 - return file->notifiable.notifications;
1.27 -}
1.28 -
1.29 -/* Close a notifier object. */
1.30 -
1.31 -void file_notify_close(file_notifier_t *notifier)
1.32 -{
1.33 - delete notifier->obj;
1.34 - delete notifier;
1.35 -}
1.36 -
1.37 -/* Obtain a local notifier object. */
1.38 -
1.39 -file_notifier_t *file_notify_local()
1.40 -{
1.41 - file_notifier_t *notifier = new file_notifier_t;
1.42 -
1.43 - notifier->obj = notifier_get_local_notifier();
1.44 - return notifier;
1.45 -}
1.46 -
1.47 -/* Obtain the task-wide notifier object. */
1.48 -
1.49 -file_notifier_t *file_notify_task()
1.50 -{
1.51 - file_notifier_t *notifier = new file_notifier_t;
1.52 -
1.53 - notifier->obj = notifier_get_task_notifier();
1.54 - return notifier;
1.55 -}
1.56 -
1.57 -/* Subscribe to notification events on a file. */
1.58 -
1.59 -long file_notify_subscribe(file_t *file, notify_flags_t flags, file_notifier_t *notifier)
1.60 -{
1.61 - return notifier->obj->subscribe(file_notifiable(file), flags);
1.62 -}
1.63 -
1.64 -/* Unsubscribe from notification events on a file. */
1.65 -
1.66 -long file_notify_unsubscribe(file_t *file, file_notifier_t *notifier)
1.67 -{
1.68 - return notifier->obj->unsubscribe(file_notifiable(file));
1.69 + return notify_notifications((notifiable_base_t *) file);
1.70 }
1.71
1.72 /* Wait for a notification event on a file. */
1.73
1.74 -long file_notify_wait_file(file_t *file, file_notifier_t *notifier)
1.75 +long file_notify_wait_file(file_t *file, notifier_t *notifier)
1.76 {
1.77 - long err = notifier->obj->wait_object(file_notifiable(file));
1.78 + long err = notify_wait(file_notifiable(file), notifier);
1.79
1.80 /* Unsubscribe if a closure notification has been received. */
1.81
1.82 - if (!err && (file->notifiable.notifications & NOTIFY_PEER_CLOSED))
1.83 - file_notify_unsubscribe(file, notifier);
1.84 + if (!err && (file_notifications(file) & NOTIFY_PEER_CLOSED))
1.85 + notify_unsubscribe(file_notifiable(file), notifier);
1.86
1.87 return err;
1.88 }
1.89
1.90 /* Wait for notification events on files. */
1.91
1.92 -long file_notify_wait_files(file_t **file, file_notifier_t *notifier)
1.93 +long file_notify_wait_files(file_t **file, notifier_t *notifier)
1.94 {
1.95 notifiable_t *notifiable;
1.96 - long err = notifier->obj->wait(¬ifiable);
1.97 + long err = notify_wait_many(¬ifiable, notifier);
1.98
1.99 *file = (file_t *) notifiable->base;
1.100
1.101 /* Unsubscribe if a closure notification has been received. */
1.102
1.103 - if (!err && ((*file)->notifiable.notifications & NOTIFY_PEER_CLOSED))
1.104 - file_notify_unsubscribe(*file, notifier);
1.105 + if (!err && (notifiable->notifications & NOTIFY_PEER_CLOSED))
1.106 + notify_unsubscribe(notifiable, notifier);
1.107
1.108 return err;
1.109 }